package org.wll.service.impl;

import org.wll.entity.Employee;
import org.wll.reporsity.EmployeeRepository;
import org.wll.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service

public class EmployeeServiceImpl implements EmployeeService {
    @Autowired
    EmployeeRepository empRepository;

    @Override
    public Employee findEmpById(Integer eid) {
        Employee emp = empRepository.findById(eid).get();
        return emp;
    }

    @Override
    public List<Employee> findAllEmps() {
        return empRepository.findAll();
    }

    @Override
    public Employee addEmp(Employee emp) {
        Employee emp1 = empRepository.save(emp);
        return emp1;
    }

    @Override
    public Employee updeEmp(Employee emp) {
        Employee emp1 = empRepository.save(emp);
        return emp1;
    }

    @Override
    public void deleteEmpById(Integer eid) {
        empRepository.deleteById(eid);
    }
}
